/*
 * Author: 李波（Edwin Lee)
 * Date: 2024-06-14 20:31:11
 * FilePath: /chat/src/server/main.cc
 * LastEditTime: 2024-06-26 21:56:04
 * version: 1.0
 * Description: 
 */

#include "chatserver.h"
#include "chatservice.h"

#include <signal.h>
#include <iostream>
using namespace std;

void resetHandler(int sig)
{
    ChatService::getInstance()->reset();
    exit(0);
}
int main(int argc, char**argv)
{
    if(argc!=3)
    {
        cout<<"wrong argv"<<endl;
        cout<<"sample:./ChatServer 127.0.0.1 6000"<<endl;
    }
    signal(SIGINT,resetHandler);
    signal(SIGTERM,resetHandler);
    EventLoop loop;
    InetAddress addr(argv[1],atoi(argv[2]));
    ChatServer server(&loop, addr, "ChatServer");

    server.start();
    loop.loop();
    return 0;
}